//
// Created by Criinal Nicole on 2020/6/15.
// 储存用户的数据结构
//

#ifndef FILESYSTEM_USER_H
#define FILESYSTEM_USER_H

namespace USER {

//    定义用户数量
    const int MAX_USER_NUM = 1024;

//    定义密码长度上限
    const int PASSWORD_SIZE = 32;

//    定义用户名长度上限
    const int USER_NAME_SIZE = 32;

//    当前用户数量
    extern int currentUserNumber;


    class User {

    public:
//        非法用户：用户Id超过用户数量上限或者权限<=0
        bool isValid();

        bool checkPassword(char *);

        bool setPassword(char *);

        bool checkName(char *);

        bool setName(char *);

        int _userId{-1};

        char _name[USER_NAME_SIZE];

        int _privilege{0};

    private:

        char _password[PASSWORD_SIZE];

    };

    extern User *Admin;

    extern User Users[MAX_USER_NUM];

    void init();

    void load();

    int addUser(User);

    User findUser(char *);
}


#endif //FILESYSTEM_USER_H
